From: Giovanni Campagna Date: Sun, 27 Feb 2011 20:46:17 +0000 (+0100) Subject: AppDisplay: allow changing categories by scrolling over them X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~8835 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=88bcd0a9cea0789c279199e26ad55782e1e0e534;p=gnome-shell.git AppDisplay: allow changing categories by scrolling over them Respond to scrolling over the app categories by changing them, so it is not required to point and click, or to use the All view. https://bugzilla.gnome.org/show_bug.cgi?id=643426 --- diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index ebc19d156..6fe12f299 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -109,7 +109,14 @@ ViewByCategories.prototype = { this._view = new AlphabeticalView(); - this._filters = new St.BoxLayout({ vertical: true }); + // categories can be -1 (the All view) or 0...n-1, where n + // is the number of sections + // -2 is a flag to indicate that nothing is selected + // (used only before the actor is mapped the first time) + this._currentCategory = -2; + this._filters = new St.BoxLayout({ vertical: true, reactive: true }); + this._filters.connect('scroll-event', Lang.bind(this, this._scrollFilter)); + this.actor.add(this._view.actor, { expand: true, x_fill: true, y_fill: true }); this.actor.add(this._filters, { expand: false, y_fill: false, y_align: St.Align.START }); @@ -123,7 +130,20 @@ ViewByCategories.prototype = { this._sections = []; }, + _scrollFilter: function(actor, event) { + let direction = event.get_scroll_direction(); + if (direction == Clutter.ScrollDirection.UP) + this._selectCategory(Math.max(this._currentCategory - 1, -1)) + else if (direction == Clutter.ScrollDirection.DOWN) + this._selectCategory(Math.min(this._currentCategory + 1, this._sections.length - 1)); + }, + _selectCategory: function(num) { + if (this._currentCategory == num) // nothing to do + return; + + this._currentCategory = num; + if (num != -1) this._allFilter.remove_style_pseudo_class('selected'); else